package com.restaurant.application.shop.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class ShopPageData extends ShopData implements PickableBean {

    public static final String FN_SAVEPATH = "savePath";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_SAVEPATH);
    
    private String savePath;

    public ShopPageData(String savePath) {
        setSavePath(savePath);
    }

    public ShopPageData() {
    }

    public ShopPageData duplicate() {
        ShopPageData result = new ShopPageData();
        result.savePath = this.savePath;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getSavePath() {
        return savePath;
    }

    public void setSavePath(String value) {
        this.savePath = value;
    }

    public ShopPageData withSavePath(String value) {
        setSavePath(value);
        return this;
    }

    public ShopPageData withSavePath(String value, String defaultValue) {
        setSavePath(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "savePath":
                return getSavePath();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ShopPageData)) return false;
        return signature().equals(((ShopPageData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ShopPageData has no signature defined, no hash code or equals possible.");
    }
}
